import { GUIComponent } from "../../../../com/mui/controls/GUIComponent";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
type int = number;
//class ProgressBase
    
    export  class ProgressBase extends GUIComponent
    {
        constructor()
        {
            super();
            setSize(95, 14);
            return;
        }

        public set progressBarClass(arg1: string)
        {
            var loc2=null;
            this._progressBarClass = arg1;
            if (this._progressBar.bitmapData) 
            {
                this._progressBar.bitmapData.dispose();
            }
            var loc1=ProgressBase.BitmapDataMap[arg1] as Object /* flash.display.BitmapData */;
            if (loc1 == null) 
            {
                loc2 = ResouceConst.getScaleBitmap(arg1);
                loc2.setSize(ProgressBase.ProgressBarWidth, 8);
                loc1 = loc2.bitmapData;
                ProgressBase.BitmapDataMap[arg1] = loc1;
            }
            this._progressBar.bitmapData = loc1;
            return;
        }

        public get progressBarClass(): string
        {
            return this._progressBarClass;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._barBg = ResouceConst.getScaleBitmap("ProgressBarBg");
            this._barBg.setSize(95, 14);
            this.addChild(this._barBg);
            this._progressBar = new Object /* flash.display.Bitmap */();
            this._progressBar.x = 7;
            this._progressBar.y = 3;
            this.addChild(this._progressBar);
            this._label = new GLabel();
            this._label.x = (this._barBg.width - this._label.width) / 2;
            this._label.y = -1;
            this._label.textField.filters = [FilterConst.glowFilter];
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 16580298);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._label.setStyle("textFormat", loc1);
            this.addChild(this._label);
            return;
        }

        public setValue(arg1: number, arg2: number): void
        {
            this._value = arg1;
            this._totalValue = arg2;
            if (arg1 > arg2) 
            {
                arg1 = arg2;
            }
            this._progressBar.width = int(arg1 / arg2 * (this._barBg.width - 14));
            this._label.text = arg1 + "/" + arg2;
            this._label.width = this._label.textField.textWidth + 10;
            this._label.x = (this._barBg.width - this._label.width) / 2;
            return;
        }

        public setValue2(arg1: number, arg2: number): void
        {
            this._value = arg1;
            this._totalValue = arg2;
            if (arg1 > arg2) 
            {
                arg1 = arg2;
            }
            this._progressBar.x = 7 + int((arg2 - arg1) / arg2 * (this._barBg.width - 14));
            this._progressBar.width = int(arg1 / arg2 * (this._barBg.width - 14));
            this._label.text = arg1 + "/" + arg2;
            this._label.width = this._label.textField.textWidth + 10;
            this._label.x = (this._barBg.width - this._label.width) / 2;
            return;
        }

        public setWidth(arg1: int): void
        {
            this._barBg.setSize(arg1, 14);
            this.width = arg1;
            this.setValue(this._value, this._totalValue);
            return;
        }

        protected /* var */_progressBar: Object /* flash.display.Bitmap */;

        protected /* var */_label: GLabel;

        protected /* var */_barBg: ScaleBitmap;

        protected /* var */_progressBarClass: string;

        protected /* var */_value: int;

        protected /* var */_totalValue: number;

        protected static /* var */BitmapDataMap: Map<any, any> /* flash.utils.Dictionary */;

        protected static /* var */ProgressBarWidth: int=101;
    }

            ProgressBase.BitmapDataMap = new Map<any, any> /* flash.utils.Dictionary */();
            ProgressBase.ProgressBarWidth = 101;
        